package DAO;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

import DTO.DTO_Local;
import DTO.DTO_PlanProdSemiElab;
import Entities.Entity_Local;
import Entities.Entity_PlanProdSemiElab;
import Hibernate.HibernateUtil;

public class DAO_PlanProdSemiElab {
		
		private static DAO_PlanProdSemiElab instancia = null;
		private static SessionFactory sf = null;

		public static DAO_PlanProdSemiElab getInstancia(){
			if(instancia == null){
				sf = HibernateUtil.getSessionFactory();
				instancia = new DAO_PlanProdSemiElab();
			} 
			return instancia;
		}
		
		public DTO_PlanProdSemiElab getPlanProdSemiElab(){
			Session session = sf.openSession();
			String consulta = "select p from Entity_PlanProdSemiElab p ";
			Query q = session.createQuery(consulta);
			Entity_PlanProdSemiElab plan = (Entity_PlanProdSemiElab) q.uniqueResult();
			DTO_PlanProdSemiElab pl = new DTO_PlanProdSemiElab();
			/*
			 * Convertir la mesa entity a mesa dto para devolver el array de dtos
			 */
	
						
			return pl;
		}
		
		public void updatePlan(DTO_PlanProdSemiElab plan){
			Entity_PlanProdSemiElab aux = new Entity_PlanProdSemiElab();
			/*
			 * convierto la mesa dto que me pasaron por parametro a la entity
			*/
			/*Abro sesion y grabo el objeto*/
			Session session = sf.openSession();
			session.beginTransaction();
			session.persist(aux);
			session.flush();
			session.getTransaction().commit();
			session.close();
		}
		

		
	
}
